<?php
use yii\helpers\Url;

$web = Url::base();
$scriptUrl = \Yii::$app->request->scriptUrl;

?>

<div class="panel panel-default">
    <div class="panel-body">
        <div class="form-inline">

            <div class="pull-right">
                <div class="form-group">
                    <div id="searchInputInstitution"></div>

                </div>
                <!--                <div class="form-group">-->
                <!--                    <label class="sr-only" for="search2">关键字</label>-->
                <!--                    <input type="text" class="form-control" id="search_key" placeholder="关键字">-->
                <!--                </div>-->
                <button id="btnSearch" type="button" class="btn btn-primary">
                    <i class="fa fa-search"></i> 搜索
                </button>
            </div>
        </div>
    </div>
</div>

<div class="panel">
    <div class="panel-body">
        <div class="table-responsive">
            <table class="table table-bordered table-hover table-condensed">
                <thead class="nowrap">
                <tr>
                    <th>用户</th>
                    <th>手机号</th>
                    <th>提现类型</th>
                    <th>提现账号</th>
                    <th>提现金额</th>
                    <th>状态</th>
                    <th>申请时间</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <?php
                foreach ($items as $item) {
                    ?>
                    <tr>
                        <td><?= $item['name'] ?></td>
                        <td><?= $item['phone'] ?></td>
                        <td>
                            <?php
                            switch ($item['type']) {
                                case 1:
                                    echo '微信';
                                    break;
                                case 2:
                                    echo '支付宝';
                                    break;
                            }
                            ?>
                        </td>
                        <td><?= $item['account'] ?></td>
                        <td><?= $item['amount'] ?></td>
                        <td>
                            <?php
                            switch ($item['status']) {
                                case 0:
                                    echo '待审核';
                                    break;
                                case 1:
                                    echo '提现成功';
                                    break;
                                case 2:
                                    echo '提现失败';
                                    break;
                            }
                            ?>
                        </td>
                        <td><?= $item['create_datetime'] ?></td>
                        <td>
                            <div class="btn-group">
                                <?php
                                //                                if ($item['status'] == 0) {
                                ?>
                                <a class="btn btn-link" data-toggle="modal" data-id="<?= $item['id'] ?>" href="#detailModal">审核</a>
                                <?php
                                //                                }
                                ?>

                            </div>
                        </td>
                    </tr>
                    <?php
                }
                ?>
                </tbody>
            </table>
        </div>
        <?= \app\widgets\LinkPagerExt::widget(['pagination' => $pagination]) ?>
    </div>
</div>

<div aria-hidden="true" role="dialog" tabindex="-1" id="detailModal" class="modal fade">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button>
                <h4 class="modal-title">提现申请</h4>
            </div>
            <div id="detail_content">
                正在加载数据....
            </div>
        </div>
    </div>
</div>

<script type="application/javascript">
    (function () {

        $('#detailModal').on('show.bs.modal', function (e) {
            $("#detail_content").html('正在加载数据....');
            var id = e.relatedTarget.attributes['data-id'].value;
            requestHtml('enchashment-record-detail-partial', {id: id}, true, function (responseHtml) {
                $("#detail_content").html(responseHtml);
            });
        });

    })(jQuery);

    //设置模态窗:当用户点击模态框外部时不会关闭、当初始化时不显示模态框。
    $(function () {
        $('#addModal').modal({
            backdrop: 'static', show: false
        });

        $('#detailModal').modal({
            backdrop: 'static', show: false
        });

    });
</script>
